package com.sg.service.biz.app.impl;

import com.sg.common.exception.Assert;
import com.sg.common.util.CommonFunctionHelper;
import com.sg.common.util.RedisUtil;
import com.sg.dto.base.app.req.QueryBusAppHypertextContentDetailReq;
import com.sg.dto.biz.app.req.UpdateHypertextContentComReqDto;
import com.sg.dto.biz.app.res.UpdateHypertextContentComRespDto;
import com.sg.entity.OmsBizAppHypertextContent;
import com.sg.service.base.app.MOmsBizAppHypertextContentService;
import com.sg.service.biz.app.HypertextContentService;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * @author ：
 * @version 1.0
 * @date ：
 */
@Service
public class HypertextContentServiceImpl implements HypertextContentService {

    @Resource
    private RedisUtil redisUtil;
    @Resource
    private MOmsBizAppHypertextContentService mOmsBizAppHypertextContentService;

    /**
     * D3修改超文本内容(公共)[10048]
     * gen by moon at 7/24/2024, 10:06:27 PM
     */
    @Trace(operationName = "D3修改超文本内容(公共)")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public UpdateHypertextContentComRespDto updateHypertextContentCom(UpdateHypertextContentComReqDto reqDto) {


        //virtualUsage 3-5-02查询业务应用超文本内容详情  71953
        OmsBizAppHypertextContent omsBizAppHypertextContent = null;
        QueryBusAppHypertextContentDetailReq queryBusAppHypertextContentDetailReq = new QueryBusAppHypertextContentDetailReq();
        if (reqDto != null) {
            queryBusAppHypertextContentDetailReq.setReleationContTypeCode(reqDto.getReleationContTypeCode());//SimpleFieldAssign//sourceId:1954246_1_71953
            queryBusAppHypertextContentDetailReq.setReleationContId(reqDto.getReleationContId());//SimpleFieldAssign//sourceId:1954247_1_71953
            queryBusAppHypertextContentDetailReq.setHypertextType(reqDto.getHypertextType());//SimpleFieldAssign//sourceId:1954251_1_71953
            queryBusAppHypertextContentDetailReq.setThemeContentId(reqDto.getThemeContentId());//SimpleFieldAssign//sourceId:1954252_1_71953
        }

        /*3-5-02查询业务应用超文本内容详情[3140]   */

        omsBizAppHypertextContent = mOmsBizAppHypertextContentService.queryBusAppHypertextContentDetail(queryBusAppHypertextContentDetailReq)/*vcase invoke 本地 method 方法调用;*/;


        if ((omsBizAppHypertextContent == null)) {
            //if(3-5-02查询业务应用超文本内容详情.出参 值等于空 )  71954

            String string = null;
            OmsBizAppHypertextContent omsBizAppHypertextContent_2 = new OmsBizAppHypertextContent();
            if (reqDto != null) {
                omsBizAppHypertextContent_2.setHypertextContent(reqDto.getHypertextContent());//SimpleFieldAssign//sourceId:1954257_1_71955
                omsBizAppHypertextContent_2.setReleationContTypeCode(reqDto.getReleationContTypeCode());//SimpleFieldAssign//sourceId:1954255_1_71955
                omsBizAppHypertextContent_2.setReleationContId(reqDto.getReleationContId());//SimpleFieldAssign//sourceId:1954256_1_71955
                omsBizAppHypertextContent_2.setHypertextType(reqDto.getHypertextType());//SimpleFieldAssign//sourceId:1954259_1_71955
                omsBizAppHypertextContent_2.setThemeContentTypeCode(reqDto.getThemeContentTypeCode());//SimpleFieldAssign//sourceId:1954260_1_71955
                omsBizAppHypertextContent_2.setThemeContentId(reqDto.getThemeContentId());//SimpleFieldAssign//sourceId:1954261_1_71955
            }

            /*3-5-2新增超文本内容[3136]   */
            Assert.isNull(omsBizAppHypertextContent_2.getHypertextContent(), "D3修改超文本内容(公共)-3-5-2新增超文本内容-超文本内容不能为空", false);
            Assert.isNull(omsBizAppHypertextContent_2.getReleationContTypeCode(), "D3修改超文本内容(公共)-3-5-2新增超文本内容-超文本内容关联类型编码不能为空", false);
            Assert.isNull(omsBizAppHypertextContent_2.getReleationContId(), "D3修改超文本内容(公共)-3-5-2新增超文本内容-超文本内容关联主键ID不能为空", false);
            Assert.isNull(omsBizAppHypertextContent_2.getHypertextType(), "D3修改超文本内容(公共)-3-5-2新增超文本内容-超文本内容类型不能为空", false);
            string = mOmsBizAppHypertextContentService.addHypertextContent(omsBizAppHypertextContent_2)/*vcase invoke 本地 method 方法调用;*/;


        } else if ((omsBizAppHypertextContent != null)) {
            //elseif(3-5-02查询业务应用超文本内容详情.出参 值不等于空 )  71956

            boolean bOOLEAN;
            if (omsBizAppHypertextContent != null) {
                OmsBizAppHypertextContent omsBizAppHypertextContent_3 = new OmsBizAppHypertextContent();
                omsBizAppHypertextContent_3.setOperationInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//CURRENT_INDUCTIONID//sourceId:1954241_1_71957
                omsBizAppHypertextContent_3.setOperateTime(CommonFunctionHelper.getCurrentTime());//SYSTEM_CURRENT_TIME//sourceId:1954242_1_71957
                if (omsBizAppHypertextContent != null) {
                    omsBizAppHypertextContent_3.setHypertextContentId(omsBizAppHypertextContent.getHypertextContentId());//SimpleFieldAssign//sourceId:1954239_1_71957
                }
                if (reqDto != null) {
                    omsBizAppHypertextContent_3.setHypertextContent(reqDto.getHypertextContent());//SimpleFieldAssign//sourceId:1954240_1_71957
                }

                /*3-3-05修改超文本内容[3626]   */
                Assert.isNull(omsBizAppHypertextContent_3.getHypertextContentId(), "D3修改超文本内容(公共)-3-3-05修改超文本内容-超文本内容ID不能为空", false);
                Assert.isNull(omsBizAppHypertextContent_3.getHypertextContent(), "D3修改超文本内容(公共)-3-3-05修改超文本内容-超文本内容不能为空", false);
                Assert.isNull(omsBizAppHypertextContent_3.getOperationInductionId(), "D3修改超文本内容(公共)-3-3-05修改超文本内容-操作人就职记录ID不能为空", false);
                Assert.isNull(omsBizAppHypertextContent_3.getOperateTime(), "D3修改超文本内容(公共)-3-3-05修改超文本内容-操作时间不能为空", false);
                bOOLEAN = mOmsBizAppHypertextContentService.updateHypertextContent(omsBizAppHypertextContent_3)/*vcase invoke 本地 method 方法调用;*/;


            }
        }
        UpdateHypertextContentComRespDto retData = new UpdateHypertextContentComRespDto();


        return retData;
    }
    //
}
